package me.aartikov.alligator.animations;


import me.aartikov.alligator.util.Log;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.ability.fraction.Fraction;
import ohos.aafwk.ability.fraction.FractionScheduler;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;

/**
 * Transition animation that uses anim resources.
 */
public class
SimpleTransitionAnimation implements TransitionAnimation {
    private int mEnterAnimation;
    private int mExitAnimation;


    /**
     * @param enterAnimation animation resource that will be used for an appearing activity/fragment
     * @param exitAnimation  animation resource that will be used for a disappearing activity/fragment
     */
    public SimpleTransitionAnimation(int enterAnimation, int exitAnimation) {
        mEnterAnimation = enterAnimation;
        mExitAnimation = exitAnimation;
    }


    @Override
    public int getEnterAnimal() {
        return mEnterAnimation;
    }

    @Override
    public int getExitAnimal() {
        return mExitAnimation;
    }

    @Override

    public Operation getActivityOptionsBundle(Ability activity) {
        return null;
    }

    @Override
    public boolean needDelayActivityFinish() {
        return false;
    }

    @Override
    public void applyBeforeActivityStarted(Ability currentActivity, Intent intent) {
    }

    @Override
    public void applyAfterActivityStarted(Ability currentActivity) {
        //TODO  overridePendingTransition
        currentActivity.setTransitionAnimation(mEnterAnimation, mExitAnimation);
//        currentActivity.overridePendingTransition(mEnterAnimation, mExitAnimation);
    }

    @Override
    public void applyBeforeActivityFinished(Ability activity) {
    }

    @Override
    public void applyAfterActivityFinished(Ability activity) {
        activity.setTransitionAnimation(mEnterAnimation, mExitAnimation);
//        activity.overridePendingTransition(mEnterAnimation, mExitAnimation);
    }

    @Override
    public void applyBeforeFragmentTransactionExecuted(FractionScheduler transaction, Fraction enteringFragment, Fraction exitingFragment) {
        //TODO
        Log.e("未完成", " fraction的切换动画设置");

//        transaction.setCustomAnimations(mEnterAnimation, mExitAnimation);
    }

    @Override
    public void applyAfterFragmentTransactionExecuted(Fraction enteringFragment, Fraction exitingFragment) {
    }
}
